package edu.sctu.practice.class01.chengongsuo.yangxu.assign2;

/**
 * Created by Administrator on 2015/10/8.
 */
public class Rational {

    private double number1 = 0;
    private double number2 = 0;
    private double resultOfPlus = 0;
    private double resultOfMinus = 0;
    private double resultOfMultiply = 0;

    private double resultOfDivide = 0;

    public Rational(double number1, double number2) {

        this.number1 = number1;
        this.number2 = number2;
    }

    public double plus() {

        resultOfPlus = number1 + number2;
        return resultOfPlus;
    }

    public double minus() {
        if (number1 >= number2) {
            resultOfMinus = number1 - number2;
        } else {
            resultOfMinus = -(number2 - number1);
        }
        return resultOfMinus;
    }

    public double multiply() {

        resultOfMultiply = number1 * number2;
        return resultOfMultiply;
    }

    public double divide() {
        if (number2 != 0) {

            resultOfDivide = number1 / number2;
        } else {

            System.out.println("please check your denominator!");

        }

        return resultOfDivide;
    }

}
